package com.pagepub.expo.manager;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.flex.remoting.RemotingInclude;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.pagepub.expo.dao.CorpProductsDao;
import com.pagepub.expo.entity.CorpProducts;
import com.pagepub.expo.entity.IdName;

@Service
@Transactional
@RemotingDestination(channels = { "my-amf", "my-secure-amf" })
public class CorpProductsMng{
	@Autowired
	private CorpProductsDao corpProductsDao;


	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<CorpProducts> findAll() {
		return corpProductsDao.findAll();
	}
	


	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public int getCount(Map<String, String> param){
		return corpProductsDao.getCount(param);
	}
	
	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<CorpProducts> findByPage(int currentPage,int pageSize,Map<String, String> param){
		return corpProductsDao.findByPage(currentPage, pageSize, param);
	}
	
	public  List<CorpProducts>  findByPage(int currentPage,int pageSize,Long corpId){
		return corpProductsDao.findByPage(currentPage, pageSize, corpId);
	}


	@RemotingInclude
	public CorpProducts add(CorpProducts corpProducts) {
		corpProductsDao.insert(corpProducts);
		return corpProductsDao.findById(new Long(corpProducts.getId()));
	}

	@RemotingInclude
	public Long remove(Long id) {
		corpProductsDao.delete(id);
		return id;
	}

	@RemotingInclude
	public CorpProducts update(CorpProducts corpProducts) {
		corpProductsDao.update(corpProducts);
		return corpProductsDao.findById(new Long(corpProducts.getId()));
	}
	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<IdName> findIdNames(){
		return corpProductsDao.findIdNames();
	}
	
	@RemotingInclude
	public void audit(Long id, boolean pass) {
		corpProductsDao.audit(id, pass);
	}
}
